package exam;

public class AnswerTest02 {

    public static void main(String[] args) {
        int arr[] = {1, 3, 4, 5, 0, 0, 6, 6, 0, 5, 4, 7, 6, 7, 0, 5};
        int count = getCount2(arr);
        System.out.println("数组中只出现一次的元素有" + count + "个");
    }
    /**
     * 出现一次的
     */
    public static int getCount2(int[] arr) {
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            int count1 = getCount(arr, arr[i]);
            if (count1 == 1) {
                count++;
            }
        }
        return count;
    }
    /**
     * 指定元素在数组中出现的次数
     */
    public static int getCount(int[] arr, int num) {
        int count = 0;

        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == num) {
                count++;
            }
        }
        return count;
    }

}
